package com.tedu.bill;

/**
 * Author：毕龙
 * Date: 2024/3/13 20:32
 */
public class TestShort {
    public static void main(String[] args) {
        //声明一个short 变量
        short s1 = 129;
        System.out.println(s1);

        //声明一个最大值
        short max = 32767;
        System.out.println(max);
        //整数的默认类型是int  JVM编译时直接报错
        //short s2 = 32768;
        //0000 0000 0000 0000 1000 0000 0000 0000
        short s2 = (short)32768;
        System.out.println(s2);

        //JVM虚拟机在遇到字面值时  编译时会直接做计算
        short s3 = 32766 + 1;
        System.out.println(s3);
        //JVM虚拟机在遇到变量时  编译时不会直接做计算 类型提升
        short s4 = 1;
        //short s5 = (short)32766 + (short)s4;
        short s5 = (short)(32766 + s4);
        System.out.println(s5);

        System.out.println("short最大值:" + Short.MAX_VALUE);
        System.out.println("short最小值:" + Short.MIN_VALUE);


    }
}
